package com.holyant.report.dto;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 销售营业利润dto
 * 
 * @author fkmalls
 * @date 2022-04-21
 */
@Data
@ApiModel("销售营业利润")
public class RptSalesOperatingProfitDto extends BaseDto {

    private static final long serialVersionUID = 1L;

    /** 报表日期精确到天 */
    @Excel(name = "报表日期精确到天")
    @ApiModelProperty(value = "报表日期精确到天")
    private String rptDay;
    /** 报表场景 10=品牌 20=销售渠道 30=订单类型 40=客户 50=店铺 60=Goods 70=SKU 80=订单来源 90=订单 */
    @Excel(name = "报表场景 10=品牌 20=销售渠道 30=订单类型 40=客户 50=店铺 60=Goods 70=SKU 80=订单来源 90=订单")
    @ApiModelProperty(value = "报表场景 10=品牌 20=销售渠道 30=订单类型 40=客户 50=店铺 60=Goods 70=SKU 80=订单来源 90=订单")
    private Integer rptScene;
    /** 来源单id */
    @Excel(name = "来源单id")
    @ApiModelProperty(value = "来源单id")
    private Long relId;
    /** 来源单号 */
    @Excel(name = "来源单号")
    @ApiModelProperty(value = "来源单号")
    private String relCode;
    /** 来源名称 */
    @Excel(name = "来源名称")
    @ApiModelProperty(value = "来源名称")
    private String relName;
    /** 销售额 */
    @Excel(name = "销售额")
    @ApiModelProperty(value = "销售额")
    private BigDecimal gmv;
    /** 毛利 */
    @Excel(name = "毛利")
    @ApiModelProperty(value = "毛利")
    private BigDecimal gp;
    /** 净利 */
    @Excel(name = "净利")
    @ApiModelProperty(value = "净利")
    private BigDecimal op;
    /** 总订单金额 */
    @Excel(name = "总订单金额")
    @ApiModelProperty(value = "总订单金额")
    private BigDecimal orderAmount;
    /** 总优惠券1 */
    @Excel(name = "总优惠券1")
    @ApiModelProperty(value = "总优惠券1")
    private BigDecimal coupon1Fee;
    /** 总优惠券2 */
    @Excel(name = "总优惠券2")
    @ApiModelProperty(value = "总优惠券2")
    private BigDecimal coupon2Fee;
    /** 总订单返利 */
    @Excel(name = "总订单返利")
    @ApiModelProperty(value = "总订单返利")
    private BigDecimal rebateFee;
    /** 总增值税费 */
    @Excel(name = "总增值税费")
    @ApiModelProperty(value = "总增值税费")
    private BigDecimal vatFee;
    /** 总关税税率 */
    @Excel(name = "总关税税率")
    @ApiModelProperty(value = "总关税税率")
    private BigDecimal vatRate;
    /** 总物流成本 */
    @Excel(name = "总物流成本")
    @ApiModelProperty(value = "总物流成本")
    private BigDecimal logisticsFee;
    /** 总跨境综合税 */
    @Excel(name = "总跨境综合税")
    @ApiModelProperty(value = "总跨境综合税")
    private BigDecimal cbTaxFee;
    /** 总供应链管理费 */
    @Excel(name = "总供应链管理费")
    @ApiModelProperty(value = "总供应链管理费")
    private BigDecimal scmFee;
    /** 总平台推广费 */
    @Excel(name = "总平台推广费")
    @ApiModelProperty(value = "总平台推广费")
    private BigDecimal platformPromotionFee;
    /** 总平台佣金 */
    @Excel(name = "总平台佣金")
    @ApiModelProperty(value = "总平台佣金")
    private BigDecimal platformCommission;
    /** 总测试及样品费 */
    @Excel(name = "总测试及样品费")
    @ApiModelProperty(value = "总测试及样品费")
    private BigDecimal sampleFee;
    /** 总销售推广费 */
    @Excel(name = "总销售推广费")
    @ApiModelProperty(value = "总销售推广费")
    private BigDecimal salesPromotionFee;
    /** 总技术服务费 */
    @Excel(name = "总技术服务费")
    @ApiModelProperty(value = "总技术服务费")
    private BigDecimal serviceFee;
    /** 总支付服务平台收费 */
    @Excel(name = "总支付服务平台收费")
    @ApiModelProperty(value = "总支付服务平台收费")
    private BigDecimal payFee;


    /** 已后一个实体为准
     * @param rptSalesOperatingProfitDto 更新实体
     * @param salesOperatingProfitDto1 数据库实体
     * @return 更新后实体
     */
    public static RptSalesOperatingProfitDto overlayPropertiesRptSalesOperatingProfitDto(RptSalesOperatingProfitDto rptSalesOperatingProfitDto,
                                                                                         RptSalesOperatingProfitDto salesOperatingProfitDto1) {
        List<RptSalesOperatingProfitDto> rptSalesOperatingProfitDtos = new ArrayList<>(2);
        rptSalesOperatingProfitDtos.add(rptSalesOperatingProfitDto);
        rptSalesOperatingProfitDtos.add(salesOperatingProfitDto1);

        salesOperatingProfitDto1.setGmv(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getGmv).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setGp(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getGp).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setOp(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getOp).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setOrderAmount(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getOrderAmount).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setCoupon1Fee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getCoupon1Fee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setCoupon2Fee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getCoupon2Fee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setRebateFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getRebateFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setVatFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getVatFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setVatRate(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getVatRate).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setLogisticsFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getLogisticsFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setCbTaxFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getCbTaxFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setScmFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getScmFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setPlatformPromotionFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getPlatformPromotionFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setPlatformCommission(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getPlatformCommission).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setSampleFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getSampleFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setSalesPromotionFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getSalesPromotionFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setServiceFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getServiceFee).reduce(BigDecimal::add).get());
        salesOperatingProfitDto1.setPayFee(rptSalesOperatingProfitDtos.stream().map(RptSalesOperatingProfitDto::getPayFee).reduce(BigDecimal::add).get());

        return salesOperatingProfitDto1;
    }


}
